package com.shm.mostRight;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        char[] chars = str.toCharArray();
        int len = chars.length;
        long value = 0;
        boolean flag=true;
        for (char aChar : chars) {
            if (chars[0] == '-') {
                flag = false;
                continue;
            }
            if (Character.isLetterOrDigit(aChar)) {
                if (value <= Long.MAX_VALUE / 10) {
                    if (Character.isDigit(aChar)) {
                        value = value * 36 + aChar - '0';
                    } else {
                        value = value * 36 + aChar - 'a' + 10;
                    }
                } else {
                    value = Long.MAX_VALUE;
                    break;
                }
            } else {
                value = 0;
                break;
            }
        }
        if (!flag) {
            value = -value;
        }
        System.out.println(value);


        for (int i = 0; i < chars.length; i++) {
            if (chars[i]>'z'||chars[i]<'0'&&chars[i]!='-'){
                System.out.println(0);
                return;
            }
        }
        if (chars[0]=='-'){
            for (int i = 1; i < chars.length; i++) {
                value += (long) ((chars[i] - '0') * Math.pow(36, len - i - 2));
                if (value>Long.MAX_VALUE/10){
                    System.out.println(-Long.MAX_VALUE);
                    return;
                }
            }
            System.out.println(-value);

        }else {
            for (int i = 0; i < chars.length; i++) {
                value += (long) ((chars[i] - '0') * Math.pow(36, len - i - 1));
                if (value>Long.MAX_VALUE/10){
                    System.out.println(Long.MAX_VALUE);
                    return;
                }
            }
            System.out.println(value);
        }


    }
}
